import subprocess
import requests
import uncurl


class __indicator__:
    def __process_link__(self):
        command = [
            "curl",
            "http://localhost:7944/api/eventmonitor/indicatorQuery/page?pageIndex=1&pageSize=10&indicator=101443704",
            "-H", "Accept: application/json",
            "-H", "Accept-Language: en-US,en;q=0.9",
            "-H", "Cache-Control: no-cache",
            "-H", "Connection: keep-alive",
            "-H", "Content-Type: application/json;charset=UTF-8",
            "-H", "Pragma: no-cache",
            "-H",
            "Referer: http://10.10.80.200:9088/children/mochaITOM/relevance-config/indicator-results/dynamic-environment-performance-index",
            "-H",
            "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
            "-H", "combine-token: 74cd9487-e16a-48a2-b136-744fc200c5c0,3ee2cde9-bade-4703-b2df-09e296ee1579",
            "--insecure"
        ]

        # 执行命令并捕获输出
        response = subprocess.run(command, capture_output=True, text=True)

        # 输出结果
        print(response.stdout)

        # if response.returncode == 0:
        #     response_data = json.loads(response.stdout)
        #     # 格式化JSON输出
        #     formatted_response_data = json.dumps(response_data, indent=4, ensure_ascii=False)
        #     # 将响应结果写入新文件
        #     with open("response3.json", "w", encoding="utf-8") as outfile:
        #         outfile.write(formatted_response_data)
        #     print("响应已成功写入文件：response3.json")
        # else:
        #     print(f"请求失败，状态码：{response.status_code}")



    def __query_uncurl__(self):
        curl_command = '''
            curl 'http://10.10.80.215:7135/api/v2/complaint/getReminderContent?insProcId=6721&type=M' \
  -H 'Accept: application/json' \
  -H 'Accept-Language: en-US,en;q=0.9' \
  -H 'Connection: keep-alive' \
  -H 'Content-Type: application/json;charset=UTF-8' \
  -H $'Cookie: \'\'; \'\'=\'\'' \
  -H 'Referer: http://10.10.80.215:9089/form-manage/proc-ins-manage/process-manage/new-process/pendingList' \
  -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36' \
  -H 'combine-token: 50fab406-fa69-478d-a7fe-648ad656b3fb,278fa723-dc6b-4ea7-8cc7-8f4260cb0474' \
  --insecure
            '''

        req = uncurl.parse_context(curl_command)

        response = requests.request(
            method=req.method,
            url=req.url,
            headers=req.headers,
            data=req.data,
            verify=False
        )

        # print(response.json())
        print(response.text)


if __name__ == '__main__':
    stance = __indicator__()
    stance.__query_uncurl__()